<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    {{message}}
    <h1>{{message}}</h1>
    <h3>{{name}}</h3>

    {{movies}}
    <ul>
      <li v-for="item in movies">{{item}}</li>
    </ul>
  </div>

  <div id="jishuqi">
    <h3>当前计数：{{counter}}</h3>
    <!-- <button v-on:click="counter++">+</button> -->
    <button v-on:click="add">-</button>
    <button @click="sub">-</button>
  </div>
  <script>
    //编程范式：声明式编程，数据与页面分离
    //es6中定义常量用const,Vue实例负责管理id为app的div
    const app = new Vue({  //对象类型
      el: '#app', //用于挂载要管理的元素
      data: {
        //定义数据
        message: '你好！',
        name: 'yuhao',
        movies: ['海王','星际穿越','大话西游','少年派的奇幻漂流']
      }
    })

    let jishu = new Vue({
      el: '#jishuqi',
      data: {
        counter: 0
      },
      methods: {
        add:function(){
          console.log('add被执行');
          this.counter++    //当前对象jishu
        },
        sub:function(){
          console.log('sub被执行');
          this.counter--
        }
      }
    })
  </script>
</body>
</html>